package com.smartnsoft.fractory;

import java.util.ArrayList;
import java.util.List;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;

import com.smartnsoft.droid4me.app.SmartActivity;
import com.smartnsoft.droid4me.framework.Commands;
import com.smartnsoft.droid4me.menu.StaticMenuCommand;

/**
 * The starting screen of the application.
 * 
 * @author Willy Noel
 * @since 2011.05.24
 */
public final class HomeActivity
    extends SmartActivity<TitleBar.TitleBarAggregate>
    implements TitleBar.TitleBarShowHomeFeature, View.OnClickListener
{
// TODO : See with Edouard how to put Text and Image together in a button.
//  private TextView title_text;

  private ImageButton modelSelectorButton;

  private ImageButton myProject;
//
//  private ImageButton imFeelingLucky;

  private Button modelSelectorButtonText;

  private Button myProjectText;
//
//  private Button imFeelingLuckyText;

  public void onRetrieveDisplayObjects()
  {
    setContentView(R.layout.home_screen);
    modelSelectorButton = (ImageButton) findViewById(R.id.modelSelector_button);
    myProject = (ImageButton) findViewById(R.id.myProjects_button);
//    imFeelingLucky = (ImageButton) findViewById(R.id.imfeelingLucky_button);
    modelSelectorButtonText = (Button) findViewById(R.id.modelSelector_button_text);
    myProjectText = (Button) findViewById(R.id.myProjects_button_text);
//    imFeelingLuckyText = (Button) findViewById(R.id.imfeelingLucky_button_text);
    
    modelSelectorButton.setOnClickListener(this);
    modelSelectorButtonText.setOnClickListener(this);
    myProject.setOnClickListener(this);
    myProjectText.setOnClickListener(this);
  }

  public void onRetrieveBusinessObjects()
      throws BusinessObjectUnavailableException
  {
  }

  public void onFulfillDisplayObjects()
  {
 
  }

  public void onSynchronizeDisplayObjects()
  {
  }

  @Override
  public List<StaticMenuCommand> getMenuCommands()
  {
    final List<StaticMenuCommand> commands = new ArrayList<StaticMenuCommand>();
    commands.add(new StaticMenuCommand(R.string.Home_menu_settings, '1', 's', android.R.drawable.ic_menu_preferences, new Commands.StaticEnabledExecutable()
    {
      @Override
      public void run()
      {
        startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
      }
    }));
    commands.add(new StaticMenuCommand(R.string.Home_menu_about, '2', 'a', android.R.drawable.ic_menu_info_details, new Commands.StaticEnabledExecutable()
    {
      @Override
      public void run()
      {
        startActivity(new Intent(getApplicationContext(), AboutActivity.class));
      }
    }));
    return commands;
  }

  public void onClick(View view)
  {
    if(view == modelSelectorButton)
    {
      startActivity(new Intent(getApplicationContext(), ModelSelectorActivity.class));
    }
    if(view == modelSelectorButtonText)
    {
        startActivity(new Intent(getApplicationContext(), ModelSelectorActivity.class));
    }
    if(view == myProject)
    {
      startActivity(new Intent(getApplicationContext(),MyProjectActivity.class));
    }
    if(view == myProjectText)
    {
        startActivity(new Intent(getApplicationContext(), MyProjectActivity.class));
    }

   
    
  }

}
